package com.robot.console.client.processors;

import com.go.core.Message;
import com.robot.console.client.Client;
import com.robot.console.client.common.ISingleClientProcessor;
import com.robot.console.core.ClientCommonParam;

public class ReconnectProcessor implements ISingleClientProcessor
{
	public static String KEY = "Reconnect";

	public static int LOGIN_SUCCESS = 0;
	@SuppressWarnings("unused")
	private static final String[] LOGIN_RESULT_STR = { "LOGIN_SUCCESS", "LOGIN_PASSWD_ERROR", "LOGIN_NICK_EXIST",
			"LOGIN_ERROR", "LOGIN_ERROR_NOUSERID", "LOGIN_SUCCESS_ADMIN", "LOGIN_NOT_ALLOW_GUEST", "LOGIN_USER_BANED",
			"LOGIN_ERROR_NOT_VALID_USERID", "LOGIN_ERROR_AUTH_URL_CONNECTION_TIMEOUT",
			"LOGIN_ERROR_AUTH_URL_RETURN_VALUE_FORMAT_ERROR", "LOGIN_DEFINE_4" };

	@Override
	public void decode(Message message, Client client)
	{
		String targetAddress = message.getAttribute("tip").getValue();
		String targetPort = message.getAttribute("tport").getValue();

		ClientCommonParam.printLogBack("Client " + client.getClientInfo().getUserId() + " need to reconnect to"
				+ " ip : " + targetAddress + " port : " + targetPort);
		client.setHost(targetAddress);
		client.setPort(Integer.parseInt(targetPort));
		client.Reconnect();
	}
}
